package com.iwhalecloud.bss.kite.cucc.service.cust;

import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.client.api.cust.ICustCheckQueryService;
import com.iwhalecloud.bss.kite.cucc.client.api.reception.ICustReceptionService;
import com.iwhalecloud.bss.kite.cucc.client.dto.scene.CuccCustInfoDTO;
import com.iwhalecloud.bss.kite.cucc.client.dto.scene.CuccCustInfoDetailDTO;
import com.iwhalecloud.bss.kite.cucc.service.pos.handler.CuccPosServiceUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CustCheckQueryService implements  ICustCheckQueryService{
    @Autowired
    private ICustReceptionService custReceptionService;
    @Override
    public boolean isYxCustType(String custId) {
        //根據custId查客戶信息
        CuccCustInfoDetailDTO cuccCustInfoDetailDTO = custReceptionService.getCustomerInfoNew(custId);
        String dataState = cuccCustInfoDetailDTO.getDataState();
        String isReal = cuccCustInfoDetailDTO.getIsReal();
        String certiCode = cuccCustInfoDetailDTO.getCertiCode();
        String certiTypeCode = cuccCustInfoDetailDTO.getCertiTypeCode();
        String bakCol1 = cuccCustInfoDetailDTO.getCust_bak_col1();
        if (KiteStringUtils.isEmpty(bakCol1)) {
            bakCol1 = cuccCustInfoDetailDTO.getEmpty_cbss_cust();
        }
        if (KiteStringUtils.isEmpty(bakCol1) || !"1".equals(bakCol1)) {
            return true;
        }
        if ("0".equals(isReal) || (!"N".equals(certiTypeCode) && KiteStringUtils.isEmpty(certiCode)) || "M".equals(dataState)) {
            return true;
        }
        CuccCustInfoDTO cuccCustInfoDTO = CuccPosServiceUtils.queryNewCustInfo(custId);
        String custState = cuccCustInfoDTO.getCustState();
        String custClassType = cuccCustInfoDTO.getCustClassType();
        String examineState = cuccCustInfoDTO.getExamineSts();
        if ("0".equals(custClassType) || "1".equals(custClassType) || "2".equals(custState)
            || "3".equals(custState) || "4".equals(custState) || !"0".equals(examineState)) {
            return true;
        }
        return false;
    }

}
